/*
 * @(#)Specification.java   09/10/12
 * 
 * Copyright (C) 2009 Ecole des Mines d'Ales
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Contact: yulinz88@gmail.com
 */



package fr.ema.arch3d.model.architecture.specification;

import fr.ema.arch3d.model.architecture.textADL.ADLDoc;

import java.util.ArrayList;
import java.util.List;

//~--- classes ----------------------------------------------------------------

/**
 * Abstract architecture specifications are the first dimension of software architecture descriptions.
 * They provides a formal and generic definition of the global structure and
 * behavior of software systems according to previously identified functional requirements.
 * They are specified during the design step of software and serve as a basis to create concrete
 * architecture configurations. The constituent elements of specification are
 *  <ul>
 * <li>Component roles
 * <li>Connections
 * <li>Architecture behavior
 * <li>Version
 * </ul>
 * <p>
 *
 *
 *
 * @version        1.0, 09/09/13
 * @author         Huaxi (Yulin) ZHANG
 */
@SuppressWarnings("unchecked")
public class Specification implements SpecificationOperation {

    /** the architecture behavior realized by this specification. */
    private List<ArchitectureBehavior> archBeh_list;

    /** the component roles composed by this specification. */
    private List<ComponentRole> cmpRole_list;

    /** the connections composed by this specification. */
    private List<Connection> connection_list;

    /** Field description */
    private ADLDoc doc;

    /** the name of this specification */
    private String name;

    /**
     * Constructs the specification with its name
     * @param name the specification name
     *
     */
    public Specification(String name) {
        this.name       = name;
        cmpRole_list    = new ArrayList();
        connection_list = new ArrayList();
        archBeh_list    = new ArrayList();
        doc             = new ADLDoc();
    }

    /**
     * Insert the component role into the specification
     * @param cmpRole the inserted component role
     */
    public void insertCmpRole(ComponentRole cmpRole) {
        cmpRole_list.add(cmpRole);
    }

    /**
     * Insert the connection into the specification
     * @param connection the inserted connection
     */
    public void insertConnection(Connection connection) {
        connection_list.add(connection);
    }

    /**
     * Insert the architecture behavior into the specification
     * @param archBeh the inserted architecture behavior
     */
    public void insertArchBeh(ArchitectureBehavior archBeh) {
        archBeh_list.add(archBeh);
    }

    /**
     * Remove the architecture behavior from the specification
     * @param archBeh the removed architecture behavior
     */
    public void removeArchBeh(ArchitectureBehavior archBeh) {
        archBeh_list.remove(archBeh);
    }

    /**
     * Remove the component role from the specification
     * @param cmpRole the removed component role
     */
    public void removeCmpRole(ComponentRole cmpRole) {
        cmpRole_list.remove(cmpRole);
    }

    /**
     * Remove the connection from the specification
     * @param connection the removed connection
     */
    public void removeConnection(Connection connection) {
        connection_list.remove(connection);
    }

    /**
     * Set the specification name
     * @param name the given specification name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Get the specification name
     * @return the specification name
     */
    public String getName() {
        return this.name;
    }

    /**
     * Get component roles in specification
     * @return the list of component roles
     */
    public List<ComponentRole> getCmpRoleList() {
        return this.cmpRole_list;
    }

    /**
     * Get connections in specification
     * @return the list of connections
     */
    public List getConnectionList() {
        return this.connection_list;
    }

    /**
     * Get architecture behaviors in specification
     * @return the list of architecture behaviors
     */
    public List getArchBehList() {
        return this.archBeh_list;
    }

    /**
     * Getter of the property <tt>doc</tt>
     *
     * @return  the doc
     */
    public ADLDoc getDoc() {
        return this.doc;
    }

    /**
     * Setter of the property <tt>doc</tt>
     *
     * @param doc  the doc to set
     */
    public void setDoc(ADLDoc doc) {
        this.doc = doc;
    }
}
